using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using DecisionMaking.Domain;
using DecisionMaking.BusinessLogic;
namespace DecisionMaking.WebApp
{
	public class BaseController : Controller
	{
		/// <summary>
		/// Injected by Windsor 
		/// </summary>
		public IAccountManager AccountManager {protected get; set;}		
		
		public Account CurrentAccount {
			get 
			{ 
				Account account = (Account)this.HttpContext.Session[typeof(Account).Name]; 
				
				// TODO remove
				if (account == null)
				{
					account = AccountManager.GetAccount(3);
					
					this.CurrentAccount = account;
				}
				
				return account;
			}

			set { this.HttpContext.Session[typeof(Account).Name] = value; }
		}
		
		public ActionResult NotFound(string message, params object[] args)
		{
			return new HttpNotFoundResult(string.Format(message, args));
		}		
		
		public ActionResult NotFound(EntityNotFoundException e)
		{
			return NotFound(e.Message, e.Data["id"]);
		}
		
		public ActionResult AccessDenied(AccessDeniedException e)
		{
			return new HttpUnauthorizedResult();
		}
		
		public ActionResult AccessDenied()
		{
			return new HttpUnauthorizedResult();
		}		
	}
	
}

